<include file="Common:doc_head"/>

	<div class="container" style="">


	   <div class="row" >
	      <div class="col-md-12" style="">
			 <empty name="data">
				  <div style="width: 100%;text-align: center;">暂无数据。。。。</div>
			<else />
	         <div class="nav col-md-3" style="overflow:auto;height: 90%;">
	         	<!-- 分类 -->
	         	<div class="btn-group btn-group-vertical">
	         	  

	         	  <volist name="nav1" id="c">
	         	  	<button class="btn" data-id="{$key}">{$c.t_name}</button>
	         	  	<div class="level2" style="">
	         	  		<volist name="c.child" id="api">
	         	  			<a data-id="{$api.id}" href="{:U('Doc/index')}?id={$api.id}&proid={$api.proid}">{$api.title}</a>
	         	  		</volist>
	         	  	</div>
	         	  </volist>

	         	</div>
	         </div>


	         <div class="content col-md-9 col-xs-12">
					<div class="item">
						<h4>{$data.title}
							<neq name="admin_user.username" value="api">
								<a href="{:U('Doc/editApi')}?id={$data.id}&proid={$proid}" style="margin-left: 2rem;">编辑</a>
								<a class="delApi" style="margin-left: 2rem;" data-id="{$data.id}">删除</a>
							</neq>
						</h4>
						<div class="item-div">
							<div class="title">接口描述：</div><span style="display: block;width: 100%;word-break: break-all;">{$data.desc|default='无'}</span>
						</div>
						<div class="item-div">
							<div class="title">接口链接：</div><span style="display: block;width: 100%;word-break: break-all;">{$data.url}</span>
						</div>
						<div class="item-div">
							<div class="title">请求方式：</div><span style="display: block;width: 100%;word-break: break-all;">{$data.request_type}</span>
						</div>
						<div class="item-div"><div class="title">调用示例：</div><a style="display: block;width: 100%;word-break: break-all;" target="_blank" href="{$data.exam_url}">{$data.exam_url|default='无'}</a></div>
						<div class="item-div">
							<h6 class="title">传参：</h6>
							<notempty name="data.params">
								<table class="table">
									<tr>
										<th>名称</th>
										<th>类型</th>
										<th>描述</th>
										<th>必填</th>
									</tr>
									<volist name="data.params" id="send">
										<tr>
											<td>{$send.p_name}</td>
											<td>{$send.p_type}</td>
											<td>{$send.p_desc}</td>
											<td><if condition="$send.p_must eq 1">是<else />否</if></td>
										</tr>
									</volist>
								</table>
							</notempty>
							<empty name="d.send">
								无
							</empty>
						</div>
						<div class="item-div">
							<h6 class="title">返回值：</h6>
						</div>
						<pre class="json" style="background: #eee;">{$data.json_str}</pre>
					</div>
	         	</empty>
	         </div>
	      </div>

	   </div>
	</div>

	<script type="text/javascript">
		$(document).ready(function(){
			var t_id='{$data.type_id}';//当前接口类别id
			if(t_id!=''){
				$('.btn[data-id="'+t_id+'"]').next('.level2').show().siblings('.level2').hide();
			}
			//当前接口id
			var api_id='{:I("id")}';
			if(api_id!=''){
				$('.level2').find("a[data-id="+api_id+"]").css('background','#eee');
			}
			$('.btn').click(function(){
				$(this).next('.level2').toggle();
			});
			//删除接口
			$('.delApi').click(function () {
				if(!confirm('确定要删除该接口？')){
					return false;
				}
				$('#waiting').show();
				$.post('{:U("Doc/delApi")}',{id:$(this).attr('data-id')},function (ret) {
					if(ret.status==200){
						window.location.href='{:U("Doc/index")}?proid={$proid}';
					}else{
						alert(ret.message);
					}
					$('#waiting').hide();
				},'json');

			});
		});
	</script>

</body>
</html>